package com.daoImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.dao.PayDao;
import com.model.Pay;

@Component("payDao")
public class PayDaoImpl implements PayDao{
	private HibernateTemplate hibernateTemplate;
	

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	public void addPay(Pay pay) {
		hibernateTemplate.save(pay);
		
	}

	public void deletePay(Pay pay) {
		hibernateTemplate.delete(pay);
		
	}

	public boolean exists(Pay pay) {
		List list=hibernateTemplate.find("from Pay pay where pay.pay_emName='"+pay.getPay_emName()+"' ");
		if(list!=null&&list.size()>0){
			return true;
		}
		else return false;
	}

	

	public List<Pay> getPayList(String hql) {
		List<Pay> payList=hibernateTemplate.find("from Pay");
		return payList;
	}

	public void updatePay(Pay pay) {
		hibernateTemplate.update(pay);
	}

	public Pay getPay(int id) {
		
		return (Pay)this.hibernateTemplate.get(Pay.class, id);
	}

}
